<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考勤管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: "Microsoft YaHei", Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }
        
        .container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            padding: 50px 60px;
            max-width: 1200px;
            width: 100%;
        }
        
        .header-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            padding-bottom: 20px;
            border-bottom: 2px solid #f0f0f0;
        }
        
        h1 {
            color: #667eea;
            margin: 0;
            font-size: 32px;
        }
        
        .subtitle {
            text-align: center;
            color: #666;
            margin-bottom: 30px;
            margin-top: 10px;
            font-size: 14px;
        }
        
        .user-section {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .user-info {
            color: #667eea;
            font-size: 15px;
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            padding: 10px 20px;
            border-radius: 25px;
            font-weight: 500;
            border: 1px solid rgba(102, 126, 234, 0.2);
        }
        
        .logout-btn {
            padding: 10px 25px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-weight: bold;
            font-size: 15px;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
            transition: all 0.3s;
        }
        
        .logout-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
        }
        
        .welcome-section {
            text-align: center;
            margin-bottom: 50px;
            padding: 40px 30px;
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
            border-radius: 20px;
            border: 1px solid rgba(102, 126, 234, 0.1);
        }
        
        .welcome-section h2 {
            color: #333;
            font-size: 32px;
            margin-bottom: 18px;
            font-weight: 600;
            letter-spacing: 1px;
        }
        
        .welcome-desc {
            color: #666;
            font-size: 17px;
            line-height: 1.8;
            max-width: 700px;
            margin: 0 auto;
        }
        
        .features-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 25px;
            margin-bottom: 50px;
        }
        
        .feature-card {
            background: #f8f9fa;
            padding: 35px 25px;
            border-radius: 16px;
            text-align: center;
            transition: all 0.3s ease;
            border: 2px solid transparent;
            cursor: default;
        }
        
        .feature-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 12px 30px rgba(102, 126, 234, 0.15);
            border-color: #667eea;
            background: white;
        }
        
        .feature-icon {
            font-size: 48px;
            margin-bottom: 15px;
            display: block;
        }
        
        .feature-card h4 {
            color: #333;
            font-size: 18px;
            margin-bottom: 10px;
            font-weight: 600;
        }
        
        .feature-card p {
            color: #666;
            font-size: 14px;
            line-height: 1.6;
        }
        
        .system-status {
            text-align: center;
            margin-bottom: 40px;
        }
        
        .status-button {
            background: white;
            border: 2px solid #667eea;
            color: #667eea;
            padding: 14px 40px;
            border-radius: 30px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            transition: all 0.3s;
            display: inline-flex;
            align-items: center;
            gap: 12px;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
        }
        
        .status-button:hover {
            background: #667eea;
            color: white;
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
        }
        
        .status-icon {
            font-size: 14px;
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        
        .nav-menu {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 25px;
            margin-top: 20px;
        }
        
        .nav-item {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 45px 30px;
            text-align: center;
            text-decoration: none;
            border-radius: 20px;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            font-weight: bold;
            position: relative;
            overflow: hidden;
            box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
        }
        
        .nav-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
            transition: left 0.5s;
        }
        
        .nav-item:hover::before {
            left: 100%;
        }
        
        .nav-item:hover {
            transform: translateY(-12px) scale(1.03);
            box-shadow: 0 20px 45px rgba(102, 126, 234, 0.5);
        }
        
        .nav-item small {
            display: block;
            margin-top: 10px;
            font-size: 13px;
            opacity: 0.9;
            font-weight: normal;
            letter-spacing: 0.5px;
        }
        
        .nav-item.disabled {
            background: #ccc;
            cursor: not-allowed;
        }
        
        .nav-item.disabled:hover {
            transform: none;
            box-shadow: none;
        }
        
        .footer {
            text-align: center;
            margin-top: 60px;
            padding-top: 30px;
            border-top: 1px solid #e9ecef;
            color: #aaa;
            font-size: 13px;
        }
        
        .footer p {
            margin: 8px 0;
            line-height: 1.6;
        }
        
        #testResult {
            margin-top: 15px;
            padding: 15px 20px;
            border-radius: 12px;
            display: none;
            max-width: 500px;
            margin-left: auto;
            margin-right: auto;
        }
        
        #testResult.success {
            background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
            border: 1px solid #28a745;
            color: #155724;
            display: block;
        }
        
        #testResult.error {
            background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
            border: 1px solid #dc3545;
            color: #721c24;
            display: block;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header-bar">
            <h1>考勤管理系统</h1>
            <div class="user-section">
                <span id="userInfo" class="user-info"></span>
                <button onclick="logout()" class="logout-btn">🚪 退出登录</button>
            </div>
        </div>
        <p class="subtitle">Attendance Management System - 课程设计项目</p>
        
        <div class="welcome-section">
            <h2>欢迎使用考勤管理系统</h2>
            <p class="welcome-desc">围绕"设置 — 记录 — 统计 — 报表"主线，为企业提供准确、及时、可追溯的考勤数据支撑</p>
        </div>
        
        <div class="features-grid">
            <div class="feature-card">
                <div class="feature-icon">⚙️</div>
                <h4>灵活配置</h4>
                <p>支持班次设置、迟到早退容差配置，适应不同管理需求</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon">📊</div>
                <h4>智能统计</h4>
                <p>自动计算出勤、请假、加班、出差数据，一键生成月度报表</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon">📥</div>
                <h4>批量处理</h4>
                <p>支持CSV批量导入打卡记录，快速导出统计报表</p>
            </div>
            <div class="feature-card">
                <div class="feature-icon">🔄</div>
                <h4>实时同步</h4>
                <p>数据实时更新，支持手工补计，确保数据准确完整</p>
            </div>
        </div>
        
        <div class="system-status">
            <button class="status-button" onclick="testConnection()">
                <span class="status-icon">●</span>
                <span id="statusText">检查系统状态</span>
            </button>
            <div id="testResult"></div>
        </div>
        
        <div class="nav-menu">
            <a href="employee.html" class="nav-item">
                <div style="font-size: 32px; margin-bottom: 10px;">👥</div>
                <div style="font-size: 18px;">员工管理</div>
                <small>Employee Management</small>
            </a>
            <a href="clock.html" class="nav-item">
                <div style="font-size: 32px; margin-bottom: 10px;">⏰</div>
                <div style="font-size: 18px;">打卡记录</div>
                <small>Clock Records</small>
            </a>
            <a href="biz.html" class="nav-item">
                <div style="font-size: 32px; margin-bottom: 10px;">📝</div>
                <div style="font-size: 18px;">业务记录</div>
                <small>Business Records</small>
            </a>
            <a href="summary.html" class="nav-item">
                <div style="font-size: 32px; margin-bottom: 10px;">📊</div>
                <div style="font-size: 18px;">考勤统计</div>
                <small>Attendance Summary</small>
            </a>
        </div>
        
        <div class="footer">
            <p>© 2025 考勤管理系统 | 课程设计项目</p>
            <p>Spring Boot 2.7.18 + MySQL 5.7</p>
        </div>
    </div>
    
    <script>
        // 检查登录状态
        const currentUser = sessionStorage.getItem('currentUser');
        if (!currentUser) {
            window.location.href = 'login.html';
        } else {
            document.getElementById('userInfo').textContent = `👤 ${currentUser}`;
        }
        
        // 退出登录
        function logout() {
            if (confirm('确定要退出登录吗？')) {
                sessionStorage.clear();
                window.location.href = 'login.html';
            }
        }
        
        async function testConnection() {
            const resultDiv = document.getElementById('testResult');
            const statusText = document.getElementById('statusText');
            const statusIcon = document.querySelector('.status-icon');
            
            resultDiv.className = '';
            resultDiv.style.display = 'none';
            statusText.textContent = '正在检测...';
            statusIcon.style.color = '#ffc107';
            
            try {
                // 测试API健康检查
                const apiResponse = await fetch('/api/health');
                const apiData = await apiResponse.json();
                
                resultDiv.className = 'success';
                statusText.textContent = '系统运行正常';
                statusIcon.style.color = '#28a745';
                resultDiv.innerHTML = `
                    <strong>✅ 系统状态良好</strong><br>
                    <p style="margin-top: 10px; font-size: 14px;">
                        服务状态: ${apiData.status}<br>
                        当前时间: ${new Date().toLocaleString('zh-CN')}
                    </p>
                `;
            } catch (error) {
                resultDiv.className = 'error';
                statusText.textContent = '系统连接失败';
                statusIcon.style.color = '#dc3545';
                resultDiv.innerHTML = `
                    <strong>❌ 无法连接到后端服务</strong><br>
                    <p style="margin-top: 10px; font-size: 14px;">
                        请确保后端服务已启动<br>
                        <small style="color: #999;">运行 ams-backend/start.bat 启动服务</small>
                    </p>
                `;
            }
        }
        
        // 页面加载时自动测试连接
        window.addEventListener('load', () => {
            setTimeout(testConnection, 1000);
        });
    </script>
</body>
</html>

